<link rel="stylesheet" href="../../admin/css/other/profile.css" />

<body>
	<div class="pear-container">
		<div class="layui-row layui-col-space10">
			<div class="layui-col-md3" >
				<div class="layui-card"  style="height: 420px">
					<div class="layui-card-body" style="padding: 25px;">
						<div class="text-center layui-text">
							<div class="user-info-head" id="userInfoHead">
								<img src="/admin/images/profile_male.jpg" id="userAvatar" width="115px" height="115px"
									alt="">
							</div>
							<h2 style="padding-top: 20px;font-size: 20px;" id="username"></h2>
							<p style="padding-top: 8px;margin-top: 10px;font-size: 13.5px;">China ， 中国</p>
						</div>
					</div>
					<div
						style="height: 45px;border-top: 1px whitesmoke solid;text-align: center;line-height: 45px;font-size: 13.5px;">
						<span>今日事 ，今日毕</span>
					</div>
				</div>
			</div>
			<div class="layui-col-md9">
				<div class="layui-card"  style="height: 420px;">
					<div class="layui-card-header">
						基本信息
					</div>
					<div class="layui-card-body">
						<form class="layui-form" style="width: 500px;" id="dialogForm" lay-filter="dialogForm"
							onsubmit="return beforeSubmit();">
							<input type="text" name="id" hidden>
							<div class="layui-form-item">
								<label class="layui-form-label required">用户名</label>
								<div class="layui-input-block">
									<input class="layui-input layui-disabled" type="text" name="username">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label required">电话</label>
								<div class="layui-input-block">
									<input class="layui-input" type="text" name="mobile" lay-verify="required|phone"
										lay-verType="tips" data-minlen="11" data-maxlen="11" autocomplete="off">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">邮箱</label>
								<div class="layui-input-block">
									<input class="layui-input" type="email" name="email" lay-verify="email"
										lay-verType="tips" autocomplete="off">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">密码</label>
								<div class="layui-input-block">
									<input class="layui-input" type="password" name="password" lay-verType="tips"
										data-maxlen="8" autocomplete="off">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">确认密码</label>
								<div class="layui-input-block">
									<input class="layui-input" type="password" name="repassword" lay-verify="euqal"
										lay-verType="tips" data-relate="password" data-tip="密码不一致" autocomplete="off">
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-input-block" align="center" style="height: auto">
									<button type="submit" class="layui-btn layui-btn-sm ">保存</button>
								</div>
							</div>
						</form>

					</div>
				</div>
			</div>
		</div>
	</div>

	<script>
		var form = layui.form;
		var request = layui.request;
		var button = layui.button;
		$(function () {
			var userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
			$("#username").text(userInfo.username);
			form.val("dialogForm", userInfo)
		})

		function beforeSubmit() {;
			var btn = button.load({elem: "#dialogForm button[type='submit']"});
			if (!form.validate(".layui-form")) {
				btn.stop();
				return false;
			}
			var data = form.val("dialogForm");
			request.postAlert('user/editSelf', data).then(res => {
				btn.stop();
			}).catch(err => {
				btn.stop();
			})
			return false;
		}
	</script>
</body>

</html>